//
//  PKLoginView.m
//  PianKe
//
//  Created by lanou on 15/12/24.
//  Copyright © 2015年 yht. All rights reserved.
//

#import "PKLoginView.h"

@implementation PKLoginView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self addDebarkView];
    }
    return self;
}

- (void)addDebarkView
{
 
    
    // 注册按钮
    _registerButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    _registerButton.tag = 300;
//    _registerButton.backgroundColor = [UIColor redColor];
    [_registerButton setTitle:@"注册" forState:(UIControlStateNormal)];
    _registerButton.titleLabel.font = [UIFont systemFontOfSize:25];
    _registerButton.frame = CGRectMake(kScreenWidth - 80 , 0 , 80, 80);
    [self addSubview:_registerButton];
    
    // 片刻大图标
    UIImageView *PKImage = [[UIImageView alloc]initWithFrame:CGRectMake(75, 80, 240, 150)];
    PKImage.image = [UIImage imageNamed:@"meiqi"];
    [self addSubview:PKImage];
    
    // 邮箱label
    UILabel *emailLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 270, 50, 30)];
    emailLabel.text = @"账号:";
    [self addSubview:emailLabel];
    
    // 账号
    _accountText = [[UITextField alloc]initWithFrame:CGRectMake(70, 270, kScreenWidth/2 + 90, 30)];
    _accountText.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self addSubview:_accountText];
    
    
    // 邮箱的线
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(30, 300, 320, 1)];
    lineView.backgroundColor = [UIColor grayColor];
    lineView.alpha = 0.2;
    [self addSubview:lineView];
    
    
    
    // 密码label
    UILabel *passLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 320, 50, 30)];
    passLabel.text = @"密码:";
    [self addSubview:passLabel];
    // 密码UITextField
    _pwdText = [[UITextField alloc]initWithFrame:CGRectMake(70, 320, kScreenWidth/2 + 90, 30)];
    _pwdText.clearButtonMode = UITextFieldViewModeWhileEditing;
    [self addSubview:_pwdText];
    
    
    // 密码的线
    UIView *passView = [[UIView alloc] initWithFrame:CGRectMake(30, 350, 320, 1)];
    passView.backgroundColor = [UIColor grayColor];
    passView.alpha = 0.2;
    [self addSubview:passView];
    
    // 登陆按钮
    _loginButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
    
    [_loginButton setBackgroundImage:[UIImage imageNamed:@"login"] forState:(UIControlStateNormal)];
    _loginButton.frame = CGRectMake(30, 370, 320, 46);
    [self addSubview:_loginButton];
    
    //  记住密码
    _rmbSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(40, 440, 60, 30)];
    
    [self addSubview:_rmbSwitch];
    
    UILabel *rmbLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 440, 80, 30)];
    rmbLabel.text = @"记住密码";
    [self addSubview:rmbLabel];
    
    
    //  自动登录
    _loginSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(200, 440, 80, 30)];
    
    [self addSubview:_loginSwitch];
    
    UILabel *loginLabel = [[UILabel alloc] initWithFrame:CGRectMake(280, 440, 80, 30)];
    loginLabel.text = @"自动登陆";
    [self addSubview:loginLabel];
    
    
    
    
    // 前线
    UIView *lineThree = [[UIView alloc] initWithFrame:CGRectMake(30, 500, (kScreenWidth - 120 - 30) / 2, 1)];
    lineThree.backgroundColor = [UIColor grayColor];
    lineThree.alpha = 0.2;
    [self addSubview:lineThree];
    // 字
    UILabel *labelTwo = [[UILabel alloc] initWithFrame:CGRectMake(lineThree.frame.origin.x + lineThree.frame.size.width, lineThree.frame.origin.y - 10, 90, 20)];
    labelTwo.text = @"合作网站登录";
    labelTwo.textAlignment = NSTextAlignmentCenter;
    labelTwo.font = [UIFont systemFontOfSize:14];
    [self addSubview:labelTwo];
    
    // 后线
    UIView *lineFour = [[UIView alloc] initWithFrame:CGRectMake(labelTwo.frame.origin.x + labelTwo.frame.size.width,lineThree.frame.origin.y, (kScreenWidth - 120 - 30) / 2, 1)];
    lineFour.backgroundColor = [UIColor grayColor];
    lineFour.alpha = 0.2;
    [self addSubview:lineFour];
    
    
    
    
    // 4个第三方按钮
    for (int i  = 0; i < 4; i++) {
        UIButton *sinaButton = [UIButton buttonWithType:(UIButtonTypeSystem)];
        sinaButton.frame = CGRectMake(10 + (i * 90), 550, 90, 70);
        switch (i) {
            case 0:
            { NSString *name = @"qq";
                 [sinaButton setBackgroundImage:[UIImage imageNamed:name] forState:(UIControlStateNormal)];
                break;
            }
            case 1:
            { NSString *name = @"renren";
                [sinaButton setBackgroundImage:[UIImage imageNamed:name] forState:(UIControlStateNormal)];
                break;
            }
            case 2:
            { NSString *name = @"douban";
                [sinaButton setBackgroundImage:[UIImage imageNamed:name] forState:(UIControlStateNormal)];
                break;
            }
            case 3:
            { NSString *name = @"weibo";
                [sinaButton setBackgroundImage:[UIImage imageNamed:name] forState:(UIControlStateNormal)];
                break;
            }
            default:
                break;
        }
       // NSString *name = [NSString stringWithFormat:@"%d",i+600];
        sinaButton.tag = 600 + i;
       
        [self addSubview:sinaButton];
    }
    
    
    
}

@end
